#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int T,n,m,l,V;
struct car{
    int d,v,a;
}c[N];
struct chao{
    int l,r;

}LR[N];
bool cmp2(chao x,chao y){
    return x.l<y.l;
}
int p[N];
int flg[N];
int lesr[N],lesl[N],ls[N];
int num=0;
void is_c(int x){
    if(c[x].v<=V&&c[x].a<=0)return;
    if(c[x].v>V&&c[x].a>=0){
        LR[++num].l=c[x].d;
        LR[num].r=l;
        return;
    }
    float tmp=(V*V-c[x].v*c[x].v)/(2*c[x].a)+c[x].d;
    int dis;
    if(tmp>l)dis=l+1;
    else dis=(int)tmp;
    if(c[x].a>0){
        if(dis>l)return;
        LR[++num].l=dis;
        LR[num].r=l;
    }else{
        LR[++num].l=c[x].d;
        if(dis<l)LR[num].r=dis;
        else LR[num].r=l;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        memset(lesl,-0x3f,sizeof(lesl));
        memset(lesr,0x3f,sizeof(lesr));
        memset(flg,0,sizeof(flg));
        num=0;
        scanf("%d %d %d %d",&n,&m,&l,&V);
        for(int i=1;i<=n;i++){
            scanf("%d %d %d",&c[i].d,&c[i].v,&c[i].a);
            is_c(i);
        }
        sort(LR+1,LR+num+1,cmp2);
        //for(int i=1;i<=num;i++){
            //cout<<LR[i].l<<' '<<LR[i].r<<endl;
        //}
        //cout<<endl;
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        sort(p+1,p+n+1);
        int numc=0,xp=1,numdel=0;
        for(int xp=1;xp<=m;xp++){
            for(int i=1;i<=num;i++){
                if(p[xp]<LR[i].l){
                    break;
                }
                if(p[xp]>LR[i].r)continue;
                if(p[xp]>=LR[i].l&&p[xp]<=LR[i].r){
                    if(!flg[i]){
                        flg[i]=1;
                        numc++;
                    }
                    lesr[xp]=min(lesr[xp],LR[i].r);
                    lesl[xp]=max(lesl[xp],LR[i].l);
                }
            }
            //cout<<lesl[xp]<<' '<<lesr[xp]<<endl;
            if(xp>=2&&p[xp]<=lesr[xp-1]){
                //cout<<p[xp]<<endl;
                if(lesr[xp]>lesr[xp-1])lesr[xp]=lesr[xp-1];
                //if(lesl[xp]<=p[xp-1]&&lesr[xp]<=lesr[xp-1])numdel++;
                numdel++;
            }

        }
        cout<<numc<<' '<<numdel<<endl;

    }

    return 0;
}

